package com.aiyige.page.my.customer.adapter;

import android.support.v4.content.ContextCompat;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.aiyige.R;
import com.aiyige.page.my.customer.model.CustomerFollowupEntity;
import com.aiyige.utils.AccountUtil;
import com.aiyige.utils.TimeUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.LinkedList;

import butterknife.ButterKnife;

/**
 * Created by xiachao
 */

public class CustomerBaseDataListAdapter extends BaseQuickAdapter<CustomerFollowupEntity, BaseViewHolder> {



    public CustomerBaseDataListAdapter() {
        super(new LinkedList<CustomerFollowupEntity>());
    }


    @Override
    protected void convert(BaseViewHolder helper, CustomerFollowupEntity item) {
        ((MyHolder) helper).bindData(item);
    }

    @Override
    protected BaseViewHolder onCreateDefViewHolder(ViewGroup parent, int viewType) {
        BaseViewHolder baseViewHolder = new MyHolder(getItemView(R.layout.item_customer_follow_up_remark, parent));
        return baseViewHolder;
    }


    public void onViewClicked() {

    }



    public class MyHolder extends BaseViewHolder {





        public MyHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }


        public void bindData(final CustomerFollowupEntity data) {
            setText(R.id.tv_follow_up_time, TimeUtils.dateToYYYYMMDDHHMM(data.getFollowupTime()));
            setText(R.id.tv_next_follow_up_value, TimeUtils.dateToYYYYMMDDHHMM(data.getNextFollowupTime()));
            setText(R.id.tv_customer_from_value, AccountUtil.getCurrentUser().getAccount());
            setText(R.id.tv_intention_product_value, data.getInterestProductValues());
//            setText(R.id.tv_follow_up_content_value, data.getFollowupContent());

            SpannableString spannableString = new SpannableString(mContext.getString(R.string.follow_up_content_tag)+data.getFollowupContent());
            spannableString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(mContext,R.color.zwcolor_black_111111)), 5,spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            ((TextView)getView(R.id.tv_follow_up_content_value)).setText(spannableString);

            SpannableString nextSpannableString = new SpannableString(mContext.getString(R.string.next_follow_up_content_tag)+data.getNextFollowupContent());
            nextSpannableString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(mContext,R.color.zwcolor_black_111111)), 7,nextSpannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            ((TextView)getView(R.id.tv_next_follow_up_content_value)).setText(nextSpannableString);

//            setText(R.id.tv_next_follow_up_content_value, data.getNextFollowupContent());
        }
    }

}
